<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
    <div id = 'foo'>
        <div id = 'son1' class="son">
            <img src="" alt="">
        </div>
        <div id = 'son2' class="son">
            <a href="" id="baidu"></a>
        </div>
    </div>
</body>
<script>
    var a = document.getElementById('baidu')
    console.log(a)
    // var foo = document.getElementById('foo')
    // console.log(foo)
    // var son1 = document.getElementById('son1')
    // console.log(son1)
    // var son2 = document.getElementById('son2')
    // console.log(son2)
    // var sons = document.getElementsByClassName('son')  //元素的数组
    // console.log(sons)
    // sons[0] //获取到一个标签对象
    // var divs = document.getElementsByTagName('div')
    // console.log(divs)
    var a2 = document.createElement('a')
    console.log(a2)
    a2.innerText = '淘宝'
    var foo = document.getElementById('foo')
    console.log(foo)

</script>
</html>